<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/index.css"/>
	</head>

	<body>
		<a href="{:U('Admin/add')}">注册</a>

		<!-- 用户列表 -->
		<table>
			<thead>
				<tr>
					<th>ID</th>
					<th>昵称</th>
					<th>密码</th>
					<th>时间</th>
					<th>等级</th>
					<th>状态</th>
					<th>操作</th>
					<th>操作</th>
					<th>操作</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<volist name="data" id="row">
					<tr>
						<td>{$row[id]}</td>
						<td onclick="AjaxUserInfo({$row[id]})">{$row[username]}</td>
						<td>{$row[password]}</td>
						<td>{:date("Y-m-d H:i:s", $row[time])}</td>
						<td>{$row[grade]}</td>
						<if condition="$row[status] eq 1">
							<td>开启</td>
							<td>
								<a href="{:U('User/status',array('id'=>$row['id'],'status'=>$row['status']))}">禁用</a>
							</td>
							<else />
							<td>禁用</td>
							<td>
								<a href="{:U('User/status',array('id'=>$row['id'],'status'=>$row['status']))}">开启</a>
							</td>
						</if>
						<td>
							<a href="{:U('User/reset',array('id'=>$row['id']))}">重置</a>
						</td>
						<td>
							<a href="{:U('User/edit',array('id'=>$row['id']))}">修改</a>
						</td>
						<td>
							<a href="{:U('User/delete',array('id'=>$row['id']))}">删除</a>
						</td>
					</tr>
				</volist>
			</tbody>

		</table>

		<!-- 分页 -->
		<nav>{$page}</nav>

		<div class="userinfo"></div>

		<script src="__PUBLIC__/js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>

		<script type="text/javascript">
			function AjaxUserInfo(user_id) {
				$.post("{:U('User/ajax_userinfo')}", {
						user_id: user_id,
					},
					function(data, status) {
						if(data != 0) {
							$(".userinfo").html(data);
						} else {
							$(".userinfo").html("该用户资料丢失！");
						}
					});
			}
		</script>
	</body>

</html>